PHP Interview Questions and Answers
Test your skills through the online practice test: PHP Quiz Online Practice Test
Related differences
Ques 6. Are objects passed by value or by reference?
Everything is passed by value.
Is it helpful?
Add Comment
View Comments
Ques 7. How do you call a constructor for a parent class?
parent::constructor($value)
Is it helpful?
Add Comment
View Comments
Ques 8. What's the special meaning of __sleep and __wakeup?
__sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.
Is it helpful?
Add Comment
View Comments
Ques 9. Why doesn't the following code print the newline properly?
$str = 'Hello, there.nHow are you?
print $str;
?>
Because inside the single quotes the n character is not interpreted as newline, just as a sequence of two characters - and n.
Is it helpful?
Add Comment
View Comments
Ques 10. Would you initialize your strings with single quotes or double quotes?
Since the data inside the single-quoted string is not parsed for variable substitution, it's always a better idea speed-wise to initialize a string with single quotes, unless you specifically need variable substitution.
Is it helpful?
Add Comment
View Comments
Most helpful rated by users:
- What does a special set of tags <?= and ?> do in PHP?
- What's the difference between include and require? -
- I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what's the problem?
- How do you define a constant?
- Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars in this example?